package com.china.zhuoyue.ui.activity.estate

import android.content.Intent
import android.view.View
import com.china.zhuoyue.databinding.ActivitySwitchHomeBinding
import com.china.zhuoyue.ui.base.BaseActivity
import com.china.zhuoyue.ui.ext.value

class SwitchHomeActivity : BaseActivity<ActivitySwitchHomeBinding>() {
    companion object {
        const val KEY_SWITCH_HOME = "KEY_SWITCH_HOME"
    }

    override fun initView() {
        loadView {
            bindViewClick(tvHome1, tvHome2, tvHome3)
        }
    }

    override fun onClick(v: View?) {
        when (v) {
            vb.tvHome1 -> switchHome(vb.tvHome1.value)
            vb.tvHome2 -> switchHome(vb.tvHome2.value)
            vb.tvHome3 -> switchHome(vb.tvHome3.value)
        }
    }

    private fun switchHome(home: String) {
        setResult(RESULT_OK, Intent().apply {
            putExtra(KEY_SWITCH_HOME, home)
        })
        finish()
    }
}